import React, { Component } from 'react'

export default class Child extends Component {
  /* static defaultProps = {
    colors: ['red', 'green', 'blue'],
  } */
  render() {
    // 等号表示默认值
    // 冒号表示重命名
    const { colors = ['red', 'green', 'blue'] } = this.props
    return (
      <div>
        Child
        <ul>
          {colors.map((item) => (
            <li key={item} style={{ backgroundColor: item }}>
              {item}
            </li>
          ))}
        </ul>
      </div>
    )
  }
}

// 静态属性
/* Child.defaultProps = {
  colors: ['red', 'green', 'blue'],
} */
